//
//  MPTMeNavigationView.m
//  MPTLive
//
//  Created by caixun on 15/8/24.
//  Copyright (c) 2015年 Jeakin. All rights reserved.
//

#import "MPTMeNavigationView.h"
#import "UIColor+MPTColor.h"


@interface MPTMeNavigationView ()

// 返回按钮
@property (nonatomic, strong) UIButton *backBtn;
// 退出按钮
@property (nonatomic, strong) UIButton *logoutBtn;
// 导航栏view背景图片
@property (nonatomic, strong) UIImageView *navBgImgv;
//
@property (nonatomic, strong) UILabel *title;

@end


@implementation MPTMeNavigationView

- (void)createNavBarView:(id)target action:(SEL)backAction logoutAction:(SEL)logoutAction
{
    // 导航栏view背景图片
    self.navBgImgv = [[UIImageView alloc] initWithFrame:self.frame];
    [self.navBgImgv setBackgroundColor:[UIColor colorWithRed:245/255.0f green:245/255.0f blue:245/255.0f alpha:1.0f]];
    self.navBgImgv.alpha = 0.0f;
    [self addSubview:self.navBgImgv];
    
    // 返回按钮
    UIImage *back = [UIImage imageNamed:@"CommonBack"];
    UIImage *backPress = [UIImage imageNamed:@"CommonBackPress"];
    self.backBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 10, 44, 60)];
    [self.backBtn addTarget:target action:backAction forControlEvents:UIControlEventTouchUpInside];
    [self.backBtn setImage:back forState:UIControlStateNormal];
    [self.backBtn setImage:backPress forState:UIControlStateHighlighted];
    [self addSubview:self.backBtn];
    
    // 添加title
    self.title = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, self.frame.size.width, self.frame.size.height-10)];
    self.title.text = @"个人中心";
    self.title.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.title];
    self.title.alpha = 0.0f;
    
    // 退出按钮
    self.logoutBtn = [[UIButton alloc] initWithFrame:CGRectMake(screenW-44-10, 10, 44, 60)];
    [self.logoutBtn setTitle:@"登出" forState:UIControlStateNormal];
    [self.logoutBtn setTitleColor:[UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0] forState:UIControlStateNormal];
    [self.logoutBtn addTarget:target action:logoutAction forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.logoutBtn];
}

- (void)setBgAlpha:(float)alphaValue
{
    self.navBgImgv.alpha = alphaValue;
    self.title.alpha = alphaValue;
}

@end
